<%@ page import="org.example.demo1.Entity.User" %>
<%@ page import="java.lang.reflect.Array" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--
* @Author: 抱羊啃1437670973@qq.com
* @Date: 2025-04-07 16:42:08
 * @LastEditors: 抱着羊啃 1437670973@qq.com
 * @LastEditTime: 2025-05-21 23:03:15
* @FilePath: \demo1\src\main\webapp\MainPage\index.jsp
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>商城管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <style>
        /* 小说排行榜样式 */
        .novel-ranking-container {
            padding: 15px;
        }
        
        .novel-rank-item {
            position: relative;
            padding: 15px;
            border-radius: 8px;
            transition: all 0.3s;
            cursor: pointer;
        }
        
        .novel-rank-item:hover {
            background-color: #f8f9fa;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.05);
        }
        
        .rank-number {
            font-size: 24px;
            font-weight: bold;
            width: 40px;
            text-align: center;
            margin-right: 15px;
        }
        
        .rank-first {
            color: #e74c3c;
        }
        
        .rank-second {
            color: #f39c12;
        }
        
        .rank-third {
            color: #2ecc71;
        }
        
        .novel-title {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .author-name {
            font-size: 14px;
        }
        
        .novel-intro {
            font-size: 14px;
            max-width: 500px;
        }
        
        .novel-tags {
            margin-top: 8px;
        }
        
        .novel-tag {
            display: inline-block;
            padding: 2px 8px;
            background-color: #f0f0f0;
            color: #666;
            border-radius: 4px;
            font-size: 12px;
            margin-right: 5px;
        }
        
        .novel-cover img {
            width: 80px;
            height: 110px;
            object-fit: cover;
        }
        
        /* 页面标题样式 */
        .section-title {
            position: relative;
            margin-bottom: 25px;
            padding-left: 15px;
            font-weight: bold;
            border-left: 4px solid #e74c3c;
        }
        
        /* 响应式调整 */
        @media (max-width: 768px) {
            .novel-intro {
                max-width: 200px;
            }
            
            .novel-cover img {
                width: 60px;
                height: 80px;
            }
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top">  <!-- 添加 fixed-top -->
    <div class="container">  <!-- 修改为 container 替代 container-fluid -->
        <a class="navbar-brand py-0" href="#">  <!-- 添加 py-0 减少纵向间距 -->
            <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/icon.jpg" alt="" width="30" height="30">
            书羊网
        </a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto">  <!-- 修改: me-3 变为 me-auto -->
                <li class="nav-item px-1">  <!-- 添加水平间距 -->
                    <a class="nav-link active" aria-current="page" href="#">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/MainPage/functionPage/library.jsp">书库</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="${pageContext.request.contextPath}/MainPage/functionPage/bookshelf.jsp">书架</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">角色扮演</a>
                </li>
                
                <c:if test="${not empty permission}">
                    <c:set var="hasAuthorPermission" value="false" />
                    <c:forEach var="perm" items="${permission}">
                        <c:if test="${perm == 2}">
                            <c:set var="hasAuthorPermission" value="true" />
                        </c:if>
                    </c:forEach>
                    
                    <c:choose>
                        <c:when test="${hasAuthorPermission}">
                            <li class="nav-item">
                                <a class="nav-link" href="${pageContext.request.contextPath}/MainPage/functionPage/authorWorkspace.jsp">作者工作台</a>
                            </li>
                        </c:when>
                        <c:otherwise>
                            <li class="nav-item">
                                <a class="nav-link" href="#">成为作者</a>
                            </li>
                        </c:otherwise>
                    </c:choose>
                </c:if>
                
            </ul>
            <form class="d-flex mx-auto" style="width: 40%; max-width: 400px;"> <!-- 修改: 添加 mx-auto 和 style -->
                <input class="form-control me-2 rounded-pill" type="search" placeholder="请输入书名或作者名" aria-label="Search">
                <!-- 添加圆角 -->
                <button class="btn btn-outline-success rounded-pill" type="submit" style="min-width: 60px;">搜索</button> <!-- 添加圆角和最小宽度 -->
            </form>
            <div class="ms-auto d-flex align-items-center gap-3 me-3"> <!-- 添加右侧间距 -->
                <a class="d-flex align-items-center text-decoration-none" href="#" style="gap:12px">
                    <img src="${user.avatar_url}" alt="用户头像"
                         class="rounded-circle shadow-sm transition-all"
                         width="45" height="45"
                         style="transition:0.3s">
                    <div class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle fw-bold text-dark p-2 rounded-3"
                           href="#"
                           role="button"
                           data-bs-toggle="dropdown"
                           style="transition:0.3s">
                            ${user.username}
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end border-0 shadow-sm">
                            <li><a class="dropdown-item py-2 text-danger rounded-2" href="${pageContext.request.contextPath}/API/user/logout">🚪 退出登录</a></li>
                        </ul>
                    </div>
                </a>
            </div>
        </div>
    </div>
</nav>
<!-- 使用Bootstrap 5的Carousel组件实现走马灯效果 -->
<div class="container-fluid p-0 mt-5">  <!-- 修改为container-fluid并移除内边距 -->
  <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
    <!-- 指示器 -->
    <div class="carousel-indicators">
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
      <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
    </div>
    
    <!-- 轮播项目 -->
    <div class="carousel-inner">
      <div class="carousel-item active">
        <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/95b4e42eced512690692d58e65acfac.png" 
             class="d-block w-100" 
             alt="Banner图片1" 
             style="object-fit: cover; height: 400px;">
      </div>
      <div class="carousel-item">
        <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/84b3bc24552c170b805e6ce4175f4f9.png" 
             class="d-block w-100" 
             alt="Banner图片2" 
             style="object-fit: cover; height: 400px;">
      </div>
      <div class="carousel-item">
        <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/4b950783b002df3b5869bc95dd8a774.png" 
             class="d-block w-100" 
             alt="Banner图片3" 
             style="object-fit: cover; height: 400px;">
      </div>
    </div>
    
    <!-- 控制按钮 -->
    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="visually-hidden">上一个</span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="visually-hidden">下一个</span>
    </button>
  </div>
</div>

<div class="container" style="padding-top: 20px;">
  <!-- 小说展示区域 -->
  <h2 class="section-title mt-4 mb-3">书羊畅销榜</h2>
  <p class="text-muted small">根据点击率、互动、专业评分综合排名</p>
  <div id="novels-container" class="row"></div>
  <div id="pagination-container" class="mt-4 d-flex justify-content-center"></div>
  
  <!-- 最新资讯区域 -->
  <h2 class="section-title mt-5 mb-3">最新资讯</h2>
  <div class="row">
    <div class="col-md-8">
      <div class="list-group">
        <a href="#" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
          <span>【新书预告】《龙与魔法》即将发布</span>
          <span class="badge bg-primary rounded-pill">新</span>
        </a>
        <a href="#" class="list-group-item list-group-item-action">2025年4月平台新书科幻类作品榜公布</a>
        <a href="#" class="list-group-item list-group-item-action">番茄网第三季度「千字奖」获奖名单</a>
        <a href="#" class="list-group-item list-group-item-action">【独家互动】读者作家互动问答活动</a>
        <a href="#" class="list-group-item list-group-item-action">番茄网平台优质作家招募计划</a>
      </div>
      <div class="text-end mt-2">
        <a href="#" class="text-decoration-none">更多 &raquo;</a>
      </div>
    </div>
    <div class="col-md-4">
      <div class="card">
        <div class="card-header bg-white">
          <strong>殿堂、金著作家</strong>
        </div>
        <div class="card-body">
          <div class="d-flex mb-2">
            <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/icon.jpg" class="rounded-circle" width="40" height="40">
            <div class="ms-2">
              <div class="fw-bold">张三</div>
              <small class="text-muted">科幻 | 已发表12部作品</small>
            </div>
          </div>
          <div class="d-flex mb-2">
            <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/icon.jpg" class="rounded-circle" width="40" height="40">
            <div class="ms-2">
              <div class="fw-bold">李四</div>
              <small class="text-muted">奇幻 | 已发表8部作品</small>
            </div>
          </div>
          <div class="d-flex">
            <img src="https://mysteriouslamb.oss-cn-hangzhou.aliyuncs.com/icon.jpg" class="rounded-circle" width="40" height="40">
            <div class="ms-2">
              <div class="fw-bold">王五</div>
              <small class="text-muted">武侠 | 已发表15部作品</small>
            </div>
          </div>
        </div>
        <div class="card-footer bg-white text-end">
          <a href="#" class="text-decoration-none">查看更多 &raquo;</a>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
        crossorigin="anonymous"></script>
<!-- 引入小说展示JS -->
<script src="${pageContext.request.contextPath}/MainPage/functionPage/novelDisplay.js"></script>
</body>
</html>